@isTest
private class AccountLevelHanderTest {

   /* static testMethod void testMethod1() {

        // //客户1
        // Account acc = TestUtils.createAccount();
        // acc.Level__c = '三级甲等';
        // insert acc;             
        
        // //业务机会1
        // Opportunity opp = TestUtils.createOpportunity();
        // opp.AccountId = acc.Id;
        // insert opp;

        // //报价1
        // Quote qt = new Quote(Name = '测试报价', OpportunityId = opp.Id);
        // insert qt;

        // //产品1  
        // Product__c p1 = TestUtils.createProduct();
        // p1.Purpose__c = '试剂报价用';
        // p1.Category1__c = '微生物';
        // insert p1;
        

        // ////测算信息1
        // Measure_Calculate__c mc = new Measure_Calculate__c(Opportunity__c = opp.Id, Quote__c = qt.Id);
        // insert mc;

        // //测算信息产品1
        // Measure_Calculate_Product__c mcp = new Measure_Calculate_Product__c(Product__c = p1.Id, Measure_Calculate__c = mc.Id);        
        // insert mcp;

        // acc.Level__c = '二级甲等';
        // update acc;

        // Opportunity p = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        // system.assertEquals('单项目', p.ProjectType__c);

         //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;
        
        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;
        system.debug(opp+'=========================');
        System.Test.startTest();
        //报价1
        Quote qt = new Quote(Name = '测试报价', OpportunityId = opp.Id);
        insert qt;

        //产品1
        Product__c p1 = TestUtils.createProduct();    
        p1.Category1__c = '微生物';
        p1.Category0__c = '仪器';
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'Test1';
        p1.Category0__c = '试剂';
        p2.Category1__c = '免疫';   
        Product__c p3 = TestUtils.createProduct(); 
        p3.Name = 'Test2';   
        p3.Category1__c = '生化';
        p3.Category0__c = '仪器';     
        insert new Product__c[] {p1, p2, p3};

        //报价产品
        QuoteProduct__c qp1 = new QuoteProduct__c(Product__c = p3.Id, Quote__c = qt.Id);
        insert qp1;

        //测算信息1
        Measure_Calculate__c mc = new Measure_Calculate__c(Opportunity__c = opp.Id);
        insert mc;

        //测算信息产品1
        Measure_Calculate_Product__c mcp1 = new Measure_Calculate_Product__c(Product__c = p1.Id, Measure_Calculate__c = mc.Id);
        Measure_Calculate_Product__c mcp2 = new Measure_Calculate_Product__c(Product__c = p2.Id, Measure_Calculate__c = mc.Id);
        insert new Measure_Calculate_Product__c[] {mcp1, mcp2};

        acc.Level__c = '二级甲等';
        update acc;
        
        Opportunity insertOpp = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        system.debug(insertOpp.Id+'=============='+insertOpp.ProjectType__c);
        system.assertEquals('多项目', insertOpp.ProjectType__c);  
    }
*/
    static testMethod void testMethod2() {

        //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;             
        
        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;        

        //产品1  
        Product__c p1 = TestUtils.createProduct();
        p1.Purpose__c = '试剂报价用';
        p1.Category1__c = '微生物';
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'Test1';
        p2.Category1__c = '免疫';
        p2.Purpose__c = '试剂报价用';
        insert new Product__c[] {p1, p2};


        //意向产品1
        IntentProduct__c ip1 = TestUtils.createIntentProduct();
        ip1.Product__c = p1.Id;
        ip1.Opportunity__c = opp.Id;
        IntentProduct__c ip2 = TestUtils.createIntentProduct();
        ip2.Product__c = p2.Id;
        ip2.Opportunity__c = opp.Id;  
        insert new IntentProduct__c[] {ip1, ip2};

        acc.Level__c = '二级甲等';
        update acc;

        Opportunity p = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        system.assertEquals('单项目', p.ProjectType__c);


    }

    static testMethod void testMethod3() {

        //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;             
        
        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;   

        //报价1
        Quote qt1 = new Quote(Name = '仪器报价',Type__c = '仪器报价',OpportunityId = opp.Id);
        //报价2
        Quote qt2 = new Quote(Name = '试剂报价',Type__c = '试剂报价',OpportunityId = opp.Id);
        insert new Quote[] { qt1, qt2 };
     

        //产品1  
        Product__c p1 = TestUtils.createProduct();
        p1.Purpose__c = '试剂报价用';
        p1.Category1__c = '微生物';
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'Test1';
        p2.Category1__c = '免疫';
        p2.Purpose__c = '试剂报价用';
        insert new Product__c[] {p1, p2};

        
        //报价产品1
        QuoteProduct__c qp1 = new QuoteProduct__c(Name = '测试报价产品1',Product__c = p1.Id,Quote__c = qt1.Id);
        QuoteProduct__c qp2 = new QuoteProduct__c(Name = '测试报价产品2',Product__c = p2.Id,Quote__c = qt2.Id);
        insert new QuoteProduct__c[] {qp1,qp2};

        acc.Level__c = '二级甲等';
        update acc;

        Opportunity p = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        system.assertEquals('单项目', p.ProjectType__c);


    
    }
}